package com.muse;

import java.util.Map;

import com.google.common.collect.Maps;

/**
 * 如果key已经存在了，则value不再被覆盖
 */
public class ComputeIfAbsentTest {
    public static void main(String[] args) {
        Map<String, Integer> map = Maps.newHashMap();
        map.computeIfAbsent("muse", k -> 100);
        map.computeIfAbsent("muse", k -> 200);
        map.computeIfAbsent("bob", k -> 100);
        System.out.println(map);
    }
}
